package com.ybwh.springboot2.common.csrf;

import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.TimeUnit;

@AllArgsConstructor
public class RedisTokenStore implements TokenStore {
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void store(String token) {
        stringRedisTemplate.opsForValue().set(token, token, 2, TimeUnit.MINUTES);
    }

    @Override
    public boolean exists(String token) {
        return stringRedisTemplate.delete(token);
    }
}